#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QMenuBar *menubar = new QMenuBar(this);
    this->setMenuBar(menubar);

    QMenu *menuParent = new QMenu("父菜单");
    QMenu *menuChild = new QMenu("子菜单");
    menubar->addMenu(menuParent);
    menuParent->addMenu(menuChild);

    QAction *action1 = new QAction("打开");
    QAction *action2 = new QAction("打开");
    menuChild->addAction(action1);
    menuChild->addAction(action2);
}

MainWindow::~MainWindow()
{
    delete ui;
}
